<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div></div>
    <script>
        function re() {
            var div = document.querySelector('div');
            var now = +new Date();
            var target = +new Date('2022-01-01 00:00:00');
            var remain = (target - now) /1000;
            var day = parseInt(remain / 60 / 60 / 24);
            var hours = parseInt(remain / 60 / 60 % 24);
            hours = hours < 10 ? '0' + hours:hours
            var min = parseInt(remain / 60 % 60); 
            min = min < 10 ? '0' + min:min
            var sec = parseInt(remain % 60);
            sec = sec < 10 ? '0' + sec:sec
            var r = '倒计时 ：' + day + ' 天 ' + hours + ' 时 ' + min + ' 分 ' + sec + ' 秒 ！！！！！' ;           div.style.color = 'red';
            div.innerHTML = r;
        }
        setInterval(re, 1000);
    </script>

</body>
</html>